<template>
	<view class="main">
		<!-- <NavigationBar origin="main" text="用户"></NavigationBar> -->
		<view class="shang" >
			<!-- <view class="header" :style="{'marginTop': `${navHeight-50}rpx`}" > -->
			<view class="header" >
				<view class="top">
					<view class="userimg">
						<view class="box">
							<image :src="User.user_image_url?User.user_image_url:'@/static/other/userimg.png'" alt="">
						</view>
					</view>
					<view class="username">
						<view class="textname">
							<view class="nickname">
								{{User.nickname?User.nickname:app_name}}
							</view>
							<view class="vip" v-if="is_vip==1">
								<image src="../../static/vip.svg"></image>
							</view>
						</view>
						<view class="textnameid">
							UID:<text class="kd" v-if="User.id">kd</text>{{User.id?User.id:''}}
							<view class="fzyqm" @click="fuzhi">
								<image src="@/static/copy.svg" mode="" v-if="User.id"></image>
							</view>
						</view>
					</view>

				</view>
				<view class="vipbox">
					<view class="box1">
						<image src="../../static/huangguan.svg" mode="widthFix"></image>
					</view>
					<view class="box2">
						<view class="viptime1" v-if="is_vip==2">会员中心</view>
						<view class="time2" v-if="is_vip==2">
							免费观看优质内容
						</view>
						<view class="viptime2" v-if="is_vip==1">会员有效时间</view>
						<view class="time1" v-if="is_vip==1">{{User.vip_expire_time}}</view>

					</view>
					<view class="box3">
						<view class="kt" @tap="open">立即开通</view>
					</view>
				</view>
			</view>
			<!-- <view class="img"  :style="{'height': `${navHeight + 360}rpx`}" > -->
			<view class="img" >
				<image src="@/static/allbg1.png" class="allbg" mode="widthFix"></image>
			</view>
		</view>

		<view class="all">
			<view class="title">
				全部功能
			</view>
			<view class="list">
				<view class="aaa" @click="goWatchHistory">
					<image src="@/static/history.svg" mode=""></image>
					<view class="bbb">
						观看记录
					</view>
				</view>
				<!-- <view class="aaa" @click="goEarnings">
					<image src="@/static/Earnings.svg" mode=""></image>
					<view class="bbb">
						我的收益
					</view>
				</view> -->
				<view class="aaa" @click="goRechargeRecord">
					<image src="@/static/jilu.svg" mode=""></image>
					<view class="bbb">
						充值记录
					</view>
				</view>
				<!-- <view class="aaa" @click="goInvite">
					<image src="@/static/Invite.svg" mode=""></image>
					<view class="bbb">
						邀请码
					</view>
				</view> -->
				<view class="aaa" @click="goWe">
					<image src="@/static/kefu.svg" mode=""></image>
					<view class="bbb">
						联系我们
					</view>
				</view>
				<view class="aaa">
					<image src="@/static/imkefu.svg" mode=""></image>
					<button class="u-reset-button bbb" open-type="im" :data-im-id="imid">在线客服</button>
				</view>
				<!-- <view class="aaa">
					<image src="@/static/desktop.svg" mode=""></image>
					<button class="u-reset-button bbb" open-type="addShortcut">添加桌面</button>
				</view> -->
			</view>
		</view>
	</view>
</template>

<script>
	import NavigationBar from '@/components/navigationBar.vue'
	import {
		Users
	} from "@/request/api.js"
	import {
		app_name
	} from "@/request/open_from.js"
	export default {
		components:{
					NavigationBar
				},
		data() {
			return {
				user_image_url: '',
				nickname: '',
				User: {},
				is_vip: 2,
				app_name: app_name,
				imid: '47823678439'
			}
		},
		onShow() {
			this.Userinfo()
		},
		methods: {
			async Userinfo() {
				let res = await Users.Userinfo()
				if (res.status_code == 200) {
					this.User = res.data
					this.is_vip = res.data.is_vip
				}
			},
			fuzhi() {
				let yqm = 'kd' + this.User.id
				uni.setClipboardData({
					data: yqm,
					showToast: false,
					success: () => {
						uni.showToast({
							title: `已复制邀请码:${yqm}`,
							icon: 'none'
						})
					}
				});
			},
			open() {
				uni.navigateTo({
					url: "/pages/Member/Member"
				})
			},
			goEarnings() {
				uni.navigateTo({
					url: `/pages/Earnings/Earnings?is_blogger=${this.User.is_blogger}`
				})
			},
			goInvite() {
				uni.navigateTo({
					url: `/pages/Invite/Invite?yqm=${this.User.is_fill_invite_code}&yqmid=${this.User.fill_invite_code}`
				})

			},
			goWe() {
				uni.navigateTo({
					url: '/pages/We/We'
				})
				// tt.navigateTo({
				// 	url: `/pages/novel_plugin/index?book_id=${750680}&chapter_id=${1}`,
				// });
			},
			goRechargeRecord() {
				uni.navigateTo({
					url: '/pages/RechargeRecord/RechargeRecord'
				})
			},
			goWatchHistory() {
				uni.navigateTo({
					url: "/pages/WatchHistory/WatchHistory"
				})
			}
		},
	}
</script>

<style lang="less" scoped>
	@import url("./User.less");
</style>